<template>
	<view>
		<p>{{weatherInfo}}</p>
		<p>{{tomorrowWeatherInfo}}</p>
		<button @click="getWeather" style="width: 80%; margin-top: 20rpx;">获取天气信息</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				weatherInfo:"",
				tomorrowWeatherInfo:""
			}
		},
		methods: {
			getWeather(){

				uni.request({
					url:"http://t.weather.sojson.com/api/weather/city/101230501",
					success: (res) => {
						if(res.data.status == 200){
console.log(res.data);
							let wendu = res.data.data.wendu;
							let weatherType = res.data.data.forecast[0].type;
							let city = res.data.cityInfo.city;
							let PM25 = res.data.data.pm25;
							this.weatherInfo ="今日天气：" + wendu + "℃ " + weatherType + " " + city + " PM" + PM25;
							
							let tomorrowWeatherInfo = res.data.data.forecast[1];
							let ymd = tomorrowWeatherInfo.ymd;
							let week = tomorrowWeatherInfo.week;
							let high = tomorrowWeatherInfo.high;
							let low = tomorrowWeatherInfo.low;
							this.tomorrowWeatherInfo = ymd + " " + week + " " + high + " " + low;
						}
					}
				})
			}
		}
	}
</script>

<style>

</style>